/* 
Scenic Graphics Library
Copyright (C) 2007 Jouni Tulkki

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USApackage scenic;
*/

package scenic;

import java.awt.Rectangle;
import java.awt.geom.AffineTransform;

import scenic.filter.BoxKernel;
import scenic.filter.Filter;

/**
 * Scene settings class is used to apply rendering settings to child nodes. 
 * in the scene graph. Currently experimental, does not work.
 */
public class SceneSettings extends SceneContainer {
	private static final Filter defaultAAFilter = new Filter(BoxKernel.getKernel(), 1.0, 1.0);
	
	private Filter antialiasingFilter;
	
	/**
	 * This filter represents the default antialiasing filter. When
	 * this filter is used, the library uses the default antialiasing algorithms
	 * of the underlying implementation.
	 */
	public static Filter getDefaultAAFilter() {
		return defaultAAFilter;
	}
	
	/**
	 * Constructs a new SceneSettings object.
	 */
	public SceneSettings() {
	}

	/**
	 * Gets the antialiasing filter that is used to antialias polygons and text.
	 * 
	 * @return the antialiasing filter
	 */
	public Filter getAntialiasingFilter() {
		return antialiasingFilter;
	}

	/**
	 * Sets the antialiasing filter that is used to antialias polygons and text.
	 * Settings the filter to null disables antialiasing.
	 * 
	 * @param antialiasingFilter the antialiasing filter
	 */
	public void setAntialiasingFilter(Filter antialiasingFilter) {
		this.antialiasingFilter = antialiasingFilter;
	}
	
	void draw(DrawContext context, AffineTransform transform, Rectangle visibleArea) {
		DrawContext newContext = context.clone();
		
		newContext.AAFilter = antialiasingFilter;		
		super.draw(newContext, transform, visibleArea);
	}	
	
	int getDrawType(DrawContext context, AffineTransform transform) {
		DrawContext newContext = context.clone();
		
		newContext.AAFilter = antialiasingFilter;
		return super.getDrawType(newContext, transform);
	}
	
	Rectangle getBounds(DrawContext context, AffineTransform transform) {
		DrawContext newContext = context.clone();
		
		newContext.AAFilter = antialiasingFilter;
		return super.getBounds(newContext, transform);
	}	
}
